var binaryTree = [1, 2, 3, 4, 5, 6, 7]

function NLR(index) {
    if (index >= binaryTree.length) {
        return
    }
    console.log(binaryTree[index])
    NLR(index * 2 + 1)
    NLR(index * 2 + 2)
}

function LNR(index) {
    if (index >= binaryTree.length) {
        return
    }
    NLR(index * 2 + 1)
    console.log(binaryTree[index])
    NLR(index * 2 + 2)
}

function LRN(index) {
    if (index >= binaryTree.length) {
        return
    }
    NLR(index * 2 + 1)
    NLR(index * 2 + 2)
    console.log(binaryTree[index])
}
console.log('---------前序遍历--------')
NLR(0)
console.log('---------中序遍历--------')
LNR(0)
console.log('---------后序遍历--------')
LRN(0)
console.log('---------层序遍历--------')
console.log(binaryTree)